package cn.edu.neu.controller.user;

import cn.edu.neu.model.Reported;
import cn.edu.neu.model.User;
import cn.edu.neu.service.ReportedService;
import cn.edu.neu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/reported")
public class ReportedController {

    @Autowired
    private UserService userService;
    @Autowired
    private ReportedService reportedService;
    @RequestMapping("/toAddPage/{id}")
    public String toAddPage(@PathVariable("id") Integer id, Model model){
        User user=userService.getUserById(id);
        model.addAttribute("user",user) ;
        return "/user/travel/reported";
    }
    @RequestMapping("/addReported")
    public String addReported(Reported reported){

        reportedService.insertReported(reported);
        return "/user/travel/reported_success";
    }
}
